package com.jml.account.activemq.listener;

import org.apache.activemq.command.ActiveMQDestination;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.TextMessage;

public class QueueMessageListener  implements MessageListener {

    //static Logger logger = LoggerFactory.getLogger(QueueMessageListener.class);

    public void onMessage(Message message) {
        try {
            ActiveMQDestination queues = (ActiveMQDestination) message.getJMSDestination();
            // 上报地理位置
            if (queues.getPhysicalName().equals("mqQueue")) {
                if (message instanceof TextMessage) {
                    TextMessage tm = (TextMessage) message;
                    String json = tm.getText();
                    System.out.println("这是发出的消息："+json);
                }

            }
        } catch (JMSException e) {
            e.printStackTrace();
        }
    }
}
